include(flags OPTIONAL)
set(VER_MAJ 3)
set(VER_MIN 3)
set(VER_PT 6)
set(fftwroot ${fftw_SOURCE_DIR})
get_filename_component(fftwroot ${fftwroot} ABSOLUTE)
include(macros.cmake)
set(externpro ${CMAKE_INSTALL_PREFIX})

#**************************************************************
#migrating from fftw-cmake_xantares
include(vs_setting.cmake)
#**************************************************************

if(MSVC)
  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  add_definitions(/Oi) # enable intrinsic functions
endif()

set(precisions double float long-double)
foreach(prec ${precisions})
  # Initializing !!!
  set(BENCHFFT_LDOUBLE 0)
  set(FFTW_LDOUBLE 0)
  set(BENCHFFT_SINGLE 0)
  set(FFTW_SINGLE 0)
  #NOTE: QUAD not yet supported
  set(BENCHFFT_QUAD 0)
  set(FFTW_QUAD 0)
  
  if(${prec} MATCHES "float")
    set(BENCHFFT_SINGLE 1)
    set(FFTW_SINGLE 1)
    set(pr "f")
  elseif(${prec} MATCHES "long-double")
    set(BENCHFFT_LDOUBLE 1)
    set(FFTW_LDOUBLE 1)
    set(pr "l")
    set(HAVE_AVX 0)
  elseif(${prec} MATCHES "double")
    set(pr "")
  endif()
  
  set(lib_name libfftw${VER_MAJ}${pr})
  if(MSVC)
    set(lib_name fftw${VER_MAJ}${pr})
  endif() 
  set(cfg_dir ${CMAKE_BINARY_DIR}/${lib_name})
  set(exe_name bench${pr})
  if(NOT EXISTS ${cfg_dir})
    execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${cfg_dir})
  endif()
  include(config.h.cmake)
  # if(NOT FFTW_LDOUBLE)
    # include(simd_setting.cmake)
  # endif()
  include(libfftw.cmake)
  include(bench.cmake)
endforeach()

#install(FILES ${fftwroot}/api/fftw3.h DESTINATION include/fftw${VER_MAJ})
install(FILES ${fftwroot}/api/fftw3.h DESTINATION include)
#install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake)
